package lcr;

public class Test0318 {
}

//没做出来
class Solution0318_1 {
    public boolean validNumber(String s) {
        int length = s.length();
        char[] chars = s.toCharArray();
        int i = 0;

        boolean isNum = false;
        i=traverseBlank(chars, i);

        int i1 = checkInteger(chars, i);
        if ((i1 != i&&(i1==length||chars[i1]!='.'))){
            i=i1;
        }else {
            return false;
        }



        return isNum;
    }

    public int checkDecimal(char[] chars, int i) {
        char now = chars[i];
        int flag = 0;
        if (now =='-'||now =='+' ){
            i++;
            flag++;
        }

        now=chars[i];
        return 0;
    }

    public int checkInteger(char[] chars, int i) {
        char now = chars[i];
        int flag = 0;
        if (now =='-'||now =='+' ){
            i++;
            flag++;
        }

        now=chars[i];
        if ('0'<=now&&now<='9'){
            i=traverseDigit(chars,i);
        }else {
            i-=flag;
        }

        return i;
    }

    public int traverseDigit(char[] chars, int i) {
        while (i < chars.length && chars[i] >= '0' && chars[i] <= '9'){
            i++;
        }

        return i;
    }

    public int traverseBlank(char[] chars, int i){
        while (i < chars.length && chars[i] == ' ') {
            i++;
        }

        return i;
    }
}
